/*
 * @Author: _LJP 2634716776@qq.com
 * @Date: 2024-02-01 20:52:09
 * @LastEditors: _LJP 2634716776@qq.com
 * @LastEditTime: 2024-02-01 23:44:34
 * @FilePath: /my_-linux/Pro24/Hashi/unordered/unorderedMap&&Set/Unordered_map.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
/*
 * @Author: _LJP 2634716776@qq.com
 * @Date: 2024-02-01 19:21:04
 * @LastEditors: _LJP 2634716776@qq.com
 * @LastEditTime: 2024-02-01 20:52:09
 * @FilePath:
 * /my_-linux/Pro24/Hashi/unordered/unorderedMap&&Set/Unordered_map.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置
 * 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once
#include <iostream>

#include "hashTable.h"


namespace HashBucket {
template <class K, class V>
class unordered_map {

  struct mapKeyOfT {//仿函数
    const K& operator()(const std::pair<K, V>& kv) { return kv.first; }
  };

    public:
     typedef typename HashTable<K, std::pair<const K, V>, mapKeyOfT>::iterator
         iterator;
     typedef typename HashTable<K, std::pair<const K, V>, mapKeyOfT>::const_iterator
         const_iterator;

     iterator begin() { return _hsT.begin(); }
     iterator end() { return _hsT.end(); }

     const_iterator begin() const { return _hsT.begin(); }
     const_iterator end() const { return _hsT.end(); }

     std::pair<iterator, bool> Insert(const std::pair<K, V>& kv) {
       return _hsT.Insert(kv);
     }

     iterator Erase(const K& key) { return _hsT.Erase(key); }

     V& operator[](const K&key){
       auto ret = _hsT.Insert(std::make_pair(key, V()));
       return ret.first->second;
     }

    protected:
    private:
     HashTable<K,const std::pair<K,V>,mapKeyOfT> _hsT;
};
}  // namespace HashBucket
